#include <iostream>
#include <chrono>
#include <thread>

/*
  https://en.cppreference.com/w/cpp/thread/sleep_for
  bool : 一个字节的数据类型
*/

struct Timer
{
    //std::chrono::time_point<std::chrono::steady_clock> start,end;
    std::chrono::_V2::system_clock::time_point start,end;
    std::chrono::duration<double, std::milli> duration;

    Timer()
    {
        start = std::chrono::high_resolution_clock::now(); //当前时间
    }

    ~Timer()
    {
        end = std::chrono::high_resolution_clock::now();
        duration = end - start;

        std::cout << "Waited " << duration.count() << " ms\n";
    }
};

void Function()
{
   Timer timer;
 
   //std::this_thread::sleep_for(std::chrono::seconds(1));
   for(int i = 0; i < 100;i ++)
   {
       std::cout << "hello\n";
   }
}


int main()
{
//    using namespace std::literals::chrono_literals; //since c++14

//     auto start = std::chrono::high_resolution_clock::now(); //当前时间
//     std::this_thread::sleep_for(std::chrono::seconds(1));

//     auto end = std::chrono::high_resolution_clock::now();
//     std::chrono::duration<double, std::milli> elapsed = end - start;
//     std::cout << "Waited " << elapsed.count() << " ms\n";

     Function();

    // int a = 6;
    // bool result = a == 5;
    // if(result)
    // {
    //     std::cout << "equal \n";
    // }
}
